<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+

class KBClientAction_send extends KBClientAction_common
{

	function &execute($controller, $manager) {
		
		$view = &$controller->getView();
		
		if(isset($this->rp->submit)) {
			
			$errors = $view->validate($this->rp->vars);	
	
			if($errors) {
				$this->rp->stripVars(true);
				$view->setErrors($errors);
				$view->setFormData($this->rp->vars);
			
			} else {
				
				$this->rp->setHtmlValues('entry_link');
				$this->rp->stripVars('stripslashes');
				
				$sent = $manager->sendToFriend($this->rp->vars);
				
				if($sent) {
					$controller->go('success_go', $this->category_id, $this->entry_id, 'friend_sent');
				
				} else {
					$this->rp->stripVars(true);
					$view->setFormData($this->rp->vars);
					$view->msg_id = 'entry_not_sent';
				}
			}
		}
			
		return $view;
	}
}
?>